import pandas as pd
from pypinyin import lazy_pinyin
from tools import *


class DataMaker:
    def __init__(self):
        self.columns = ['text', 'label']
        self.df = pd.DataFrame([], columns=self.columns)

        self.name_df = pd.read_excel('my_data/names.xlsx')
        self.institution_df = pd.read_excel('my_data/institutions.xlsx')

    def get_cn_info(self):
        pass

    def get_en_info(self):
        pass

    def get_context_dc(self):
        pass

    def get_prefix_of_title(self):
        pass

    def get_title(self):
        pass

    def get_authors(self):
        pass

    def get_institutions(self):
        pass

    def get_summary(self):
        pass

    def get_content(self):
        pass





name_df = pd.read_excel('my_data/names.xlsx')
name_df

institution_df = pd.read_excel('my_data/institutions.xlsx')
institution_df




# name_zh = '张海峰'
# name_zh = '李四'
# name_zh = '四'
name_zh = '诸葛孔明'
conv_name_from_zh_to_en(name_zh)

# import numpy as np
# np.random.choice([1, 2, 3], size=3, replace=False)
# # np.shuffle
# np.shu

seed = 42
# shuffled_names = names.sample(frac=1, random_state=seed)
# # shuffled_names = names.sample(frac=1, random_state=seed + 1)
# # shuffled_names = names.sample(frac=1, random_state=seed + 2)
# shuffled_names['name'].tolist()
name_df.sample
sample_n = 3
sampled_df = name_df.sample(n=sample_n, random_state=seed)
name_zh_ls = sampled_df['name'].tolist()
name_zh_ls

name_en_ls = [conv_name_from_zh_to_en(name_zh) for name_zh in name_zh_ls]
name_en_ls

from tools import template_replace

template_file_path = 'templates/style_1.html'
prefix_of_title = '12345'
context_dc = {
    'prefix_of_title': prefix_of_title,
    'cn_info': {
        'title': '这是标题',
        'authors': '张三, 李四, 王五.',
        'institutions': '1.北京大学\n2.清华大学.',
        'summary': '这是摘要...',
    },
    'en_info': {
            'title': 'Title_1',
            'authors': 'Zhang San, Li Si.',
            'institutions': '1. Beijing University;\n2. Qing Hua University.',
            'summary': 'summary...',
        },
    'content': '正文内容...',
}

replaced_content = template_replace(template_file_path, context_dc)
print(replaced_content)











